#include<bits/stdc++.h>
using namespace std;
int n,q;
signed main(){
	ios::sync_with_stdio(0);
	freopen("replace.in","r",stdin);
	freopen("replace.out","w",stdout);
	cin>>n>>q;
	while(n--){
		string s1,s2;
		cin>>s1>>s2;
	} 
	int m=q;
	while(q--){
		string ss,sss;
		cin>>ss>>sss; 
	}
	while(m--) cout<<"0"<<endl;
	return 0;
} 
